package com.matrix.java.chap_05.example;

import java.util.Scanner;

/*
    将十进制数转换为十六进制数
 */
public class Case5_11 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("十进制数: ");
        int decimal = input.nextInt();
        String output = "";
        do {
            int num = decimal % 16;
            String numS = String.valueOf(num);
            switch (num) {
                case 10:
                    numS = "A";
                    break;
                case 11:
                    numS = "B";
                    break;
                case 12:
                    numS = "C";
                    break;
                case 13:
                    numS = "D";
                    break;
                case 14:
                    numS = "E";
                    break;
                case 15:
                    numS = "F";
            }
            output = numS + output;
            decimal /= 16;
        } while (decimal != 0);
        System.out.println(output);
        input.close();
    }
}
